package interfaceCustomer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import Controller.PDF;
public class MaintanceParkingSpotPanel extends JFrame implements ActionListener {
	
	
	private Integer[] s={1,2,3};
	JComboBox spotlist = new JComboBox(s);
	private Integer[] l={1,2,3};
	JComboBox levellist = new JComboBox(l);
	SetupPanel sp = new SetupPanel();
	private Integer[] r=new Integer[sp.getsize()];
	JComboBox rawlist;
	private  JLabel  lblraw,lbllevel,lblspot;
	private JButton btnBackToMenu, btnSelect;
	
	PDF p = new PDF();

	public MaintanceParkingSpotPanel(){
		sp.setVisible(false);
		int i;
		for(i=0;i<sp.getsize();i++)
			r[i]=i+1;
		rawlist = new JComboBox(r);
		
		setTitle("Parking Under Maintenance");
		this.setSize(440, 286);
		this.getContentPane().setLayout(null);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		lblraw = new JLabel("Select Raw");
		lblraw.setBounds(63, 92, 97, 25);
		getContentPane().add(lblraw);
		
		lbllevel = new JLabel("Select Level");
		lbllevel.setBounds(63, 55, 97, 25);
		getContentPane().add(lbllevel);
		
		lblspot = new JLabel("Select Spot");
		lblspot.setBounds(63, 123, 97, 25);
		getContentPane().add(lblspot);
		
		spotlist.setSelectedIndex(0);
		spotlist.setBounds(183, 128, 57, 25);
		getContentPane().add(spotlist);
		spotlist.addActionListener(this); 
		
		levellist.setSelectedIndex(0);
		levellist.setBounds(183, 55, 57, 25);
		getContentPane().add(levellist);
		levellist.addActionListener(this); 
		
		rawlist.setSelectedIndex(0);
		rawlist.setBounds(183, 92, 57, 25);
		getContentPane().add(rawlist);
		rawlist.addActionListener(this);
		
		btnBackToMenu = new JButton("Back To Menu");
		btnBackToMenu.setBounds(45, 215, 115, 25);
		getContentPane().add(btnBackToMenu);
		btnBackToMenu.addActionListener(this);
		
		btnSelect = new JButton("Select");
		btnSelect.setBounds(283, 215, 115, 25);
		getContentPane().add(btnSelect);
		btnSelect.addActionListener(this);
		
		sp.setVisible(false);
		this.setVisible(true);
		System.out.println(r.length);
		
		
		
		
		
	}
	
	public void validateInput() {
	}

	public void sendMessageForMaintanceParkingSpot() {
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
	int level=(int)levellist.getSelectedItem();
	p.setLevel(level);
	int raw=(int)rawlist.getSelectedItem();
	p.setRaw(raw);
	int spot=(int)spotlist.getSelectedItem();
	p.setSpot(spot);
	p.setfalg(1);
        if(e.getSource().equals(btnSelect))
        {
        this.setVisible(false);
		JOptionPane.showMessageDialog(this,"You Selected: Level: "+level+", Raw: "+raw+", Spot:"+spot,"OK",JOptionPane.INFORMATION_MESSAGE);
        PDF p;
        //p.writeStatusPic(level, raw,spot, sp.raw);
        
        }
        if(e.getSource() == btnBackToMenu)
        {
        	this.setVisible(false);
        	new WorkerGui();
        }
		
	}

}